package com.base.view.dialog;

import android.os.Bundle;
import android.widget.ImageView;

import com.base.control.MActivitySupport;
import com.base.control.MDialog;
import com.base.framework.R;

/**
 * Created by yjh on 15-3-13.
 */
public class LoadingDialog extends MDialog {
    private MActivitySupport mActivity;
    ImageView imageView;

    public LoadingDialog(MActivitySupport context) {
        this(context,  R.style.MDialogNoFLoatingStyle);
    }

    public LoadingDialog(MActivitySupport context, int theme) {
        super(context, theme);
        if(context instanceof MActivitySupport) {
            mActivity = (MActivitySupport)context;
        } else {
            throw new RuntimeException("请在MActivitySupport中使用该Dialog");
        }
    }

    public LoadingDialog(MActivitySupport context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        if(getContext() instanceof MActivitySupport) {
            mActivity = (MActivitySupport)getOwnerActivity();
        } else {
            throw new RuntimeException("请在MActivitySupport中使用该Dialog");
        }
    }

    @Override
    public void create(Bundle savedInstanceState) {
        setContentView(R.layout.dialog_loading);

        imageView = mfindViewById(R.id.loading_image);


        mActivity.setImageView(imageView, R.drawable.loading, MActivitySupport.ImageLoaderType.DEFAULT, false);
    }
}
